using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace RenameX.Rules
{
    public abstract class RuleBase : IRenameRule, INotifyPropertyChanged
    {
        public abstract string Name { get; }

        private bool _isEnabled = false;
        public bool IsEnabled 
        { 
            get => _isEnabled; 
            set => SetProperty(ref _isEnabled, value); 
        }

        public abstract string Apply(string originalName);

        public event PropertyChangedEventHandler? PropertyChanged;

        protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string? propertyName = null)
        {
            if (Equals(storage, value)) return false;
            storage = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
            return true;
        }
    }
}


